package com.hanzhong.travel.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 密码加密测试工具类
 */
public class PasswordEncoderTest {
    
    public static void main(String[] args) {
        // 创建BCrypt密码编码器
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        // 需要加密的密码
        String rawPassword = "123456";
        
        // 加密密码
        String encodedPassword = encoder.encode(rawPassword);
        
        // 打印结果
        System.out.println("原始密码: " + rawPassword);
        System.out.println("加密后密码: " + encodedPassword);
        System.out.println("加密后密码长度: " + encodedPassword.length());
        
        // 验证密码
        boolean matches = encoder.matches(rawPassword, encodedPassword);
        System.out.println("验证结果: " + matches);
        
        // 为测试用户生成密码
        String testPassword = "test123";
        String testEncodedPassword = encoder.encode(testPassword);
        System.out.println("\n测试用户密码: " + testPassword);
        System.out.println("测试用户加密后密码: " + testEncodedPassword);
        System.out.println("测试用户加密后密码长度: " + testEncodedPassword.length());
    }
} 